package com.zyh.day05.loadsave

import org.apache.spark.sql.{DataFrame, SparkSession}

object JsonTest {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder()
      .master("local[*]")
      .appName("pt")
      .getOrCreate()

    val list = List((1, "xiao1hei", 18), (2, "xiao2hei", 20), (3, "xiao3hei", 22), (4, "xiao4hei", 23))
    import spark.implicits._
    val df: DataFrame = list.toDF("id", "name", "age")

    //df.write.json("file:///D:/data/json")
    val result: DataFrame = spark.read.json("file:///D:/data/json")
    result.show()

    spark.close()
  }
}
